package com.gy.api.pc.filings.controller;


import com.github.pagehelper.PageInfo;
import com.gy.api.base.*;
import com.gy.api.pc.filings.domain.vo.PageScriptRecordVO;
import com.gy.api.pc.filings.domain.vo.ScriptRecordSearchVO;
import com.gy.api.pc.filings.domain.vo.ScriptRecordAddVO;
import com.gy.api.pc.filings.domain.vo.ScriptRecordUpdateVO;
import com.gy.api.pc.filings.service.IPatentApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/script/record/info")
@Api( tags = ApiIndex.ScriptRecordInfoController)
public class ScriptRecordInfoController {

    @Autowired
    IPatentApplicationService scriptRecordInfoService;


    @GetMapping("/page")
    @ApiOperation(value = "剧本备案信息管理-公示列表")
    public R<RestPage<PageScriptRecordVO>> page(@ApiParam(value = "查询参数") @ModelAttribute  ScriptRecordSearchVO searchVO) {
        List<PageScriptRecordVO> list = scriptRecordInfoService.scriptRecordPublicityInfo(searchVO);
        RestPage restPage = new RestPage( new PageInfo(list),list);
        return new R(restPage);
    }
//
//    @GetMapping("/detail")
//    @ApiOperation(value = "剧本备案信息管理-详情")
//    public R<ScriptRecordAddVO> detail(@RequestParam(value = "id", required = true) String id) {
//        ScriptRecordAddVO vo = scriptRecordInfoService.getScriptRecordInfodetail(id);
//        return new R(vo);
//    }


    @PostMapping("/add")
    @ApiOperation(value = "剧本备案信息管理-回执单保存")
    public R saveReceipt(@RequestBody ScriptRecordAddVO addVO) {
        scriptRecordInfoService.saveReceipt(addVO);
        return new R();
    }


    @PostMapping("/update")
    @ApiOperation(value = "剧本备案信息管理-回执单保存")
    public R saveReceipt(@RequestBody ScriptRecordUpdateVO updateVO) {
        scriptRecordInfoService.updateReceipt(updateVO);
        return new R();
    }


    @PostMapping("/del")
    @ApiOperation(value = "剧本备案信息管理-删除")
    public R<String> delReceipt(@RequestBody IDEntity id) {
        scriptRecordInfoService.removeReceiptById(id.getId());
        return new R();
    }

    @PostMapping("/del_batch")
    @ApiOperation(value = "剧本备案信息管理-批量-删除")
    public R<String> delReceipt(@RequestBody IDsEntity iDsEntity) {
        scriptRecordInfoService.removeReceiptByIds(iDsEntity.getIds());
        return new R();
    }


}

